// import moment from "moment/min/moment-with-locales.js";   //所有语言包
import moment from 'moment';
import "moment/dist/locale/zh-cn.js";  

export const dateFormat = (date:any)=>{
  //一天的时间戳：86400000 一年的时间戳：31536000000
  // return moment.locales(); //查语言列表
  moment.locale("zh-cn");
  const diff = Math.abs(moment(date, "YYYY/MM/DD HH:mm:ss").diff(moment()));

  if (diff < 86400000) {
    return moment(date, "YYYY/MM/DD HH:mm:ss").startOf("second").fromNow();
  } else if (diff < 31536000000) {
    return moment(date, "YYYY/MM/DD HH:mm:ss").format("MM-DD");
  }else{
    return moment(date, "YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD");
  }
}

export const dateFormat2 = (date: any) => {
  //一天的时间戳：86400000 一年的时间戳：31536000000
  // return moment.locales(); //查语言列表
  moment.locale("zh-cn");
  const diff = Math.abs(moment(date, "YYYY/MM/DD HH:mm:ss").diff(moment()));
  if (diff < 31536000000) {
    return moment(date, "YYYY/MM/DD HH:mm:ss").format("MM-DD");
  } else {
    return moment(date, "YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD");
  }
};